<?php

namespace App\Repositories\Criteria\Article;

use App\Repositories\Contracts\CriteriaInterface;
use App\Repositories\Contracts\RepositoryInterface as Repository;
use App\Repositories\Contracts\RepositoryInterface;
use App\Repositories\Criteria\Criteria;

class Title extends Criteria
{
    /**
     * 标题
     *
     * @var
     */
    protected $title;

    /**
     * Title constructor.
     * @param $title
     */
    public function __construct($title)
    {
        $this->title = $title;
    }

    /**
     * @param $model
     * @param RepositoryInterface $repository
     * @return mixed
     */
    public function apply($model, Repository $repository)
    {
        $query = $model->where('title', 'like', '%' . $this->title .'%');
        return $query;
    }
}